home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 2 / Amiga Tools 2.iso / grafik / bildanzeiger / seepix / source.lha / CloseDisp.c < prev    next >
C/C++ Source or Header  |  1992-11-27  |  6KB  |  156 lines

  1. /**CloseDisp.c***********************************************************
  2.  *                                    *
  3.  *   SeePix -- by Hank Schafer                        *
  4.  *                                    *
  5.  *   SeePix is an IFF Picture Viewer.  It works with Lo-Res,        *
  6.  *   Med-Res, Hi-Res, HAM, and EHB formats.  I'm working on support     *
  7.  *   for X-Specs, and Anim5 formats.                    *
  8.  *                                    *
  9.  *   SeePix is based on a program by Olaf Barthel, called        *
  10.  *   'LoadImage'.  As released, LoadImage had a couple of bugs.     *
  11.  *   The Amiga-Key alternatives to menu use didn't all work.  That's    *
  12.  *   been fixed.  There were two separate print functions in LoadImage    *
  13.  *   which behaved exactly the same.  The redundancy was eliminated.    *
  14.  *   LoadImage used the Topaz ROMFONT, and made no allowances for a    *
  15.  *   different system default font (under 2.04).  I added a built-in    *
  16.  *   font.  I've reworked the code considerably from the original       *
  17.  *   release, to allow for optimizations based on time and space.    *
  18.  *                                    *
  19.  *   SeePix features a palette tool which allows "tweaking" of colors    *
  20.  *   prior to printing, allowing you to modify the color printout to    *
  21.  *   more closely resemble the original graphics (Blue is Blue, not    *
  22.  *   Purple).  SeePix can be Iconified.  SeePix features an ARP     *
  23.  *   interface.  SeePix now uses the PathMaster File Selector.        *
  24.  *                                    *
  25.  ************************************************************************
  26.  *                                                                      *
  27.  *   SeePix Copyright © 1992 by Hank Schafer; all rights reserved.      *
  28.  *                                                                      *
  29.  *   This program is free software; you can redistribute it and/or      *
  30.  *   modify it under the terms of the GNU General Public License as     *
  31.  *   published by the Free Software Foundation, either version 1, or    *
  32.  *   (at your option) any later version.                                *
  33.  *                                                                      *
  34.  *   This program is distributed in the hope that it will be useful,    *
  35.  *   but WITHOUT ANY WARRANTY; without even the implied warranty of     *
  36.  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU  *
  37.  *   General Public License for more details.                           *
  38.  *                                                                      *
  39.  *   You should have received a copy of the GNU General Public License  *
  40.  *   along with this program; if not, write to:                         *
  41.  *                 Free Software Foundation, Inc.                       *
  42.  *                 675 Massachusetts Ave.                               *
  43.  *                 Cambridge  MA  02139, USA                            *
  44.  *                                                                      *
  45.  **************** Special Function Copyright Notices ********************
  46.  *                                    *
  47.  ****LoadImage Copyright Notice:                    *
  48.  *                                    *
  49.  *   LoadImage is © Copyright 1988, 1989, 1990 by MXM, all rights    *
  50.  *   reserved, written by Olaf Barthel.  No guarantees of any kind are    *
  51.  *   made that this program is 100% reliable.  Use this program on    *
  52.  *   your own risk!                            *
  53.  *                                    *
  54.  ****Iconify Copyright Notice:                        *
  55.  *                                    *
  56.  *   Copyright 1987 by Leo L. Schwab.                    *
  57.  *   Permission is hereby granted for use in any and all programs,    *
  58.  *   both Public Domain and commercial in nature, provided this     *
  59.  *   Copyright notice is left intact.                    *
  60.  *                                    *
  61.  ****ColorWindow (Palette) Copyright Notice:                *
  62.  *                                    *
  63.  * ColorWindow Routine    --  Color Window Routines            *
  64.  *     from Book 1 of the Amiga Programmers' Suite by RJ Mical          *
  65.  *                                    *
  66.  * Copyright (C) 1986, 1987, Robert J. Mical                *
  67.  * All Rights Reserved.                         *
  68.  *                                    *
  69.  ****PathMaster Copyright Notice:                    *
  70.  *                                    *
  71.  * -------------------------------------------------------------------- *
  72.  *   Copyright © 1989 Justin V. McCormick.  All Rights Reserved.    *
  73.  * -------------------------------------------------------------------- *
  74.  *                                    *
  75.  *    The PathMaster name is a trademark of Justin V. McCormick.    *
  76.  *                                    *
  77.  *   PathMaster File Selector source and documentation written by:    *
  78.  *                                    *
  79.  *             Justin V. McCormick.                *
  80.  *           Copyright © 1989 by Justin V. McCormick.         *
  81.  *             All Rights Reserved.                *
  82.  *                                    *
  83.  * -------------------------------------------------------------------- *
  84.  ************************************************************************
  85.  *                                    *
  86.  *   Hope this is something you can use and enjoy.            *
  87.  *                                    *
  88.  ************************************************************************/
  89.  
  90. /*
  91.  * CloseDisp()
  92.  *
  93.  * Closes anything that we have opened but the libraries.
  94.  */
  95.  
  96. extern struct Screen *Screen;
  97. extern struct Window *Window;
  98.  
  99. extern struct BitMap ScreenMap;
  100. extern struct BitMap TinyBitMap;
  101. extern struct NewScreen NewScreen;
  102.  
  103. BitMapHeader    InfoHeader;
  104.  
  105. VOID
  106. CloseDisp()
  107. {
  108.     WORD        i;
  109.  
  110.     /* Canst thou hear me? Finish what you have started. */
  111.  
  112.     ClearCycle();
  113.  
  114.     /* A window! */
  115.  
  116.     if (Window) {
  117.  
  118.     /* Hide the menu. */
  119.  
  120.     Window->Flags |= RMBTRAP;
  121.  
  122.     /* We don't need the menu any more. */
  123.  
  124.     ClearMenuStrip(Window);
  125.  
  126.     CloseWindow(Window);
  127.  
  128.     Window = NULL;
  129.     }
  130.     /* Is there a screen anywhere? */
  131.  
  132.     if (Screen) {
  133.     CloseScreen(Screen);
  134.  
  135.     Screen = NULL;
  136.     }
  137.     /* Get rid of the planes. */
  138.  
  139.     for (i = 0; i < ScreenMap.Depth; i++) {
  140.     if (TinyBitMap.Planes[i]) {
  141.         FreeRaster(TinyBitMap.Planes[i], InfoHeader.w, InfoHeader.h);
  142.         TinyBitMap.Planes[i] = NULL;
  143.  
  144.         if (ScreenMap.Planes[i]) {
  145.         FreeRaster(ScreenMap.Planes[i], NewScreen.Width, NewScreen.Height);
  146.         ScreenMap.Planes[i] = NULL;
  147.         }
  148.         continue;
  149.     }
  150.     if (ScreenMap.Planes[i]) {
  151.         FreeRaster(ScreenMap.Planes[i], InfoHeader.w, InfoHeader.h);
  152.         ScreenMap.Planes[i] = NULL;
  153.     }
  154.     }
  155. }
  156.